package com.robusta.cityuate.objects;

import java.util.Calendar;

import com.robusta.cityuate.services.CommentonSpotService;
import com.robusta.cityuate.services.HTTPService;
import com.robusta.cityuate.utils.ConnectionUtils;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class Comment {
	
	
	User user;
	Calendar time;
	String body;
	long id;
	Spot spot;
	
	public static final String COMMENT_BODY="body";
	public static final String COMMENT="comment";
	
	
	 public Comment(String text) {
		 this.body=text;
		 user=new User(10, "Jessica", "Peirce");
		 time=Calendar.getInstance();
	}
	 
	 public Comment(User user,String body,Spot spot) {
		 this.user=user;
		 this.body=body;
		 this.spot=spot;
		 this.time=Calendar.getInstance();
	}
	 
	 public Comment(User user,String body,Spot spot,Calendar time) {
		 this.body=body;
		 this.spot=spot;
		 this.time=time;
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}


	public Calendar getTime() {
		return time;
	}


	public void setTime(Calendar time) {
		this.time = time;
	}


	public String getBody() {
		return body;
	}


	public void setBody(String body) {
		this.body = body;
	}


	public long getId() {
		return id;
	}


	public void setId(long id) {
		this.id = id;
	}
	
	
	public void send(Context context,String tag){
		
		if (!ConnectionUtils.isNetworkAvailable(context)) // {
			// No connection
			ConnectionUtils.showNoConnectionDialog(context);
		// return;
		// } else { // Connection is available
		// start back-ground service to handle Create process
		Intent backgroud_regService = new Intent(context,
				CommentonSpotService.class);
		backgroud_regService.setAction(tag);

		backgroud_regService.putExtra(HTTPService.LOGIN_RQUIRED, true);
		backgroud_regService.putExtra(Spot.SPOT, spot);
		backgroud_regService.putExtra(Comment.COMMENT_BODY,body);

		context.startService(backgroud_regService);
		Log.e(tag, "Fired ReportSpot service");
	}
	

}
